package lab02.test21;

public class Test {
    //统计一个字符串中给定字符出现的频率

        public static void main(String[] args) {
            //统计数字6出现的次数
            char c = '6';
            String string = "123344466675895323435325242411";
            System.out.println(getCharCount(c, string));
        }
        //遍历
        public static int getCharCount(char c, String string){
            int count = 0;
            for (int i = 0; i < string.length(); i++) {
                char temp = string.charAt(i);
                if(c == temp)
                    count ++;
            }
            return count;
        }
    }

